package cn.jdy.plugins.entity;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import java.io.Serializable;

/**
 * Created by Tianyi on 2014/7/31.
 */
@Embeddable
public class CollectPK implements Serializable {

	@Column(nullable = false, length = 32)
	private String userId;// 会员ID
	@Column(nullable = false, length = 32)
	private String businessId;// 商机ID

	public CollectPK() {
	}

	public CollectPK(String userId, String businessId) {
		this.userId = userId;
		this.businessId = businessId;
	}

	@Override
	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((userId == null) ? 0 : userId.hashCode());
		result = PRIME * result + ((businessId == null) ? 0 : businessId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if(this == obj) return true;
		if(obj == null) return false;
		if(getClass() != obj.getClass()) return false;
		final CollectPK other = (CollectPK) obj;
		if(userId == null) {
			if(other.userId != null) return false;
		} else if(!userId.equals(other.userId)) return false;
		if(businessId == null) {
			if(other.businessId != null) return false;
		} else if(!businessId.equals(other.businessId)) return false;
		return true;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getBusinessId() {
		return businessId;
	}

	public void setBusinessId(String businessId) {
		this.businessId = businessId;
	}
}
